package com.hqq.rabbitmq.consumer;

import com.hqq.rabbitmq.entity.Person;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

/**
 * 对象类型消息的消费者
 * @author huangqiqin
 * @date 2021/04/16 22:13
 **/
@Component
public class ObjectMessageConsumer {

    /**
     * 监听并接收消息队列中的消息，这里采用多消息容器工厂实例
     * @param person
     */
    @RabbitListener(queues = "${mq.object.queue.name}", containerFactory = "multiListenerContainer")
    public void consumeMessage(@Payload Person person){
        System.out.println("==> 接收到RabbitMQ消息：" + person);
    }
}
